// store/modules/user.js
const state = {
  userInfo: {
	  userId: 0,
	  username: '',
	  identity: 0,
	  name: '',
	  sex: '',
	  age: '',
	  contact: '',
	  image: '',
	  signature: '',
	  workId: ''
  },
}

const mutations = {
  SET_USER_INFO(state, info) {
    state.userInfo = info
  },
    CLEAR_USER_INFO(state) {
      state.userInfo = {
        userId: 0,
        username: '',
        identity: 0,
        name: '',
        sex: '',
        age: '',
        contact: '',
        image: '',
        signature: '',
        workId: ''
      };
    }
}

const actions = {
  setUserInfo({ commit }, info) {
    commit('SET_USER_INFO', info)
  },
    clearUserInfo({ commit }) {
      commit('CLEAR_USER_INFO');
    }
}

const getters = {
  getUserInfo: state => state.userInfo
}

export default {
  state,
  mutations,
  actions,
  getters
}